{include file='public/meta' }
<title>用户配置 - 木鱼内容管理系统</title>
<style>
	.form1 {
	    display: flex;
	}
</style>
	</head>
	<body>
		<div class="wrap">
			<div class="layui-card">
				<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
				    <legend>生成栏目</legend>
				  </fieldset>
			<div class="layui-row layui-col-space10">
				<div class="layui-col-md4">
					<form class="layui-form">
						<input type="hidden" name="mid" value="1">
						<div class="form1">
					    <div class="layui-form-item">
					        <label class="layui-form-label">按照id生成</label>
					        <div class="layui-input-block">
					            <div id="cateid">
									
								</div>
					        </div>
					    </div>
						<div class="layui-form-item">
					    <button type="submit" lay-submit lay-filter="cateid" class="layui-btn">开始生成</button>
						</div>
						</div>
					</form>
				</div>
				<div class="layui-col-md4">
					<form class="layui-form">
						<input type="hidden" name="mod" value="1">
						<div class="form1">
					    <div class="layui-form-item">
					        <label class="layui-form-label">按照模型</label>
					        <div class="layui-input-block">
					            <div id="modid">
					            	
					            </div>
					        </div>
					    </div>
						<div class="layui-form-item">
						<button type="submit" lay-submit lay-filter="modid" class="layui-btn">开始生成</button>
						</div>
						</div>
					</form>
				</div>
				<div class="layui-col-md4">
					<form class="layui-form">
						<input type="hidden" name="all" value="1">
					    <div class="layui-form-item">
					        <label class="layui-form-label">生成所有</label>
							<button type="submit" lay-submit lay-filter="all" class="layui-btn">生成所有</button>
					    </div>
					    
					</form>
				</div>
			</div>
			</div>
			<div class="layui-card">
				<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
				    <legend>生成内容</legend>
				  </fieldset>
			<div class="layui-row layui-col-space10">
				<div class="layui-col-md4">
					<form class="layui-form">
						<input type="hidden" name="mid" value="1">
						<div class="form1">
					    <div class="layui-form-item">
					        <label class="layui-form-label">按照栏目</label>
					        <div class="layui-input-block">
					            <div id="mcateids">
									
								</div>
					        </div>
					    </div>
						<div class="layui-form-item">
					    <button type="submit" lay-submit lay-filter="mcateids" class="layui-btn">开始生成</button>
						</div>
						</div>
					</form>
				</div>
				<div class="layui-col-md4">
					<form class="layui-form">
						<input type="hidden" name="mod" value="1">
						<div class="form1">
					    <div class="layui-form-item">
					        <label class="layui-form-label">按照模型</label>
					        <div class="layui-input-block">
					            <div id="mmodids">
					            	
					            </div>
					        </div>
					    </div>
						<div class="layui-form-item">
						<button type="submit" lay-submit lay-filter="mmodids" class="layui-btn">开始生成</button>
						</div>
						</div>
					</form>
				</div>
				<div class="layui-col-md4">
					<form class="layui-form">
						<input type="hidden" name="all" value="1">
					    <div class="layui-form-item">
					        <label class="layui-form-label">生成所有</label>
							<button type="submit" lay-submit lay-filter="mall" class="layui-btn">生成所有</button>
					    </div>
					    
					</form>
				</div>
			</div>
			
			<div style="padding: 10px; background-color: #FAFAFA;">
			  <div class="layui-row layui-col-space15">
			    <div class="layui-col-md13">
			    <div class="layui-card">
			        <div class="layui-card-header muyu-text">选中项操作</div>
			        <div class="layui-card-body">
			            <span style="display:inline-block;">选中项：</span>
			        <div class="layui-btn-container" style="display:inline-block;">
			          <a class="layui-btn layui-btn-xs layui-btn-normal" onclick="createall()" href="javascript:;">生成选中</a>
			        </div>
			        </div>
			    </div>
			    </div>  
			</div>    
			</div>
			
			
			<div class="layui-row layui-col-space10">
				<div class="layui-col-md4" style="text-align: center;" id="prepage">
					
				</div>
				<div class="layui-col-md4" style="text-align: center;">
					<span>当前第{$matlist['thispages']}页,共{$matlist['pages']}页,{$matlist['sum']}条数据</span>
				</div>
				<div class="layui-col-md4" style="text-align: center;" id="nextpage">
					
				</div>
			</div>
			
			
			<div class="layui-card-body">
			<div class="layui-table-body layui-table-main">
				<table class="layui-table" id="LAY-user-front-submit">
					<thead>
						<tr>
							<th class=" layui-table-col-special">
								<div class="layui-table-cell laytable-cell-checkbox">
									<input type="checkbox" id="checkAll" onclick="isCheck()">
								</div>
							</th>
							<th>
								<div class="layui-table-cell" align="center"><span>id</span></div>
							</th>
							<th>
								<div class="layui-table-cell" align="center"><span>文章标题</span></div>
							</th>							
							<th>
								<div class="layui-table-cell" align="center"><span>发布者</span></div>
							</th>
							<th>
								<div class="layui-table-cell" align="center"><span>发布时间</span></div>
							</th>
							<th>
								<div class="layui-table-cell" align="center"><span>状态</span></div>
							</th>
						</tr>
					</thead>
				        
					<tbody>
						{foreach $matlist['allmats'] as $val}
						<tr align="center">
							<td class="layui-table-col-special">
								<input type="checkbox" name="fav" value="{$val.id},{$val.mid}">
							</td>
							<td>{$val.id}</td>
							<td>{$val.title}</td>
							<td>{$val.author}</td>
							<td>{$val.create_time|date='Y/m/d'}</td>
							<td>
								<div class="layui-table-cell">
									<a
										class="layui-btn-xs layui-btn layui-btn-{if ($val.status == '0') }btn{elseif $val.status == '1' }normal{elseif $val.status == '2' }danger{/if}"><i
											class="layui-icon layui-icon-{if ($val.status == '0') }ok{elseif $val.status == '1' }edit{elseif $val.status == '2' }close{/if}"></i>
										{if ($val.status == '0') }
										已发布
										{elseif $val.status == '1' }
										草稿
										{elseif $val.status == '2' }
										已下架
										{/if}
									</a>
									<a class="layui-btn layui-btn-primary {if ($val.top == '1')}layui-bg-red{/if} layui-btn-xs">顶</a>
									<a class="layui-btn layui-btn-primary {if ($val.ppts == '1')}layui-bg-blue{/if} layui-btn-xs">幻</a>
								</div>
							</td>
						</tr>
						{/foreach}
					</tbody>
				</table>
			</div>
			</div>
			
			</div>
		</div>
{include file='public/footer' }
		{load href="__ADMINST__muyuadmin/xm-select.js"}
		<script>
		layui.config({
		  base: '__ADMINST__layuiadmin/' //静态资源所在路径
		  ,version: new Date().getTime()
		}).extend({
		  index: 'lib/index' //主入口模块
		}).use(['index', 'form'], function(){
		  var $ = layui.$
		  ,form = layui.form ;
		  
		  form.on('submit(cateid)', function(data){
		      var D = data.field;
			  var input = selectcate.getValue('valueStr');
			  if(!/^\s*$/g.test(input)){
				  D['mids'] = input;
				  ajaxcrea(D,"{:url('admin/Createdata/createlist')}");
			  }else{
				  selectcate.warning('#ff0000', true);
				  layer.msg("请选择栏目",{time:2000,icon:2});
			  }
		      return false;
		  });
		  form.on('submit(modid)', function(data){
		    var D = data.field;
		    var input = selectmodid.getValue('valueStr');
		    if(!/^\s*$/g.test(input)){
		    	D['mods'] = input;
		    	ajaxcrea(D,"{:url('admin/Createdata/createlist')}");
		    }else{
		    	selectmodid.warning('#ff0000', true);
		    	layer.msg("请选择模型",{time:2000,icon:2});
		    }
		    return false;
		  });
		  form.on('submit(all)', function(data){
		    var D = data.field;
		  		ajaxcrea(D,"{:url('admin/Createdata/createlist')}");
		      return false;
		  });
		  
		  
		  
		  form.on('submit(mcateids)', function(data){
		      var D = data.field;
		  			  var input = mselectcate.getValue('valueStr');
		  			  if(!/^\s*$/g.test(input)){
		  				  D['mids'] = input;
		  				  ajaxcrea(D,"{:url('admin/Createdata/createmater')}");
		  			  }else{
		  				  mselectcate.warning('#ff0000', true);
		  				  layer.msg("请选择栏目",{time:2000,icon:2});
		  			  }
		      return false;
		  });
		  form.on('submit(mmodids)', function(data){
		    var D = data.field;
		    var input = mselectmodid.getValue('valueStr');
		    if(!/^\s*$/g.test(input)){
		    	D['mods'] = input;
		    	ajaxcrea(D,"{:url('admin/Createdata/createmater')}");
		    }else{
		    	mselectmodid.warning('#ff0000', true);
		    	layer.msg("请选择模型",{time:2000,icon:2});
		    }
		    return false;
		  });
		  form.on('submit(mall)', function(data){
		    var D = data.field;
		  		ajaxcrea(D,"{:url('admin/Createdata/createmater')}");
		      return false;
		  });
		  
		})
		var html,sum=1,htmls,checkpage,checkpages;
		checkpage = {$matlist['thispages']}-sum;
		checkpages = {$matlist['thispages']}+sum;
		if(checkpage >= sum){
			html = "<a href='?page="+checkpage+"'>";
			html +=		"<button type='button' class='layui-btn'>上一页</button>";
			html +=	"</a>";
		}else{
			html = "<button type='button' class='layui-btn layui-btn-disabled'>上一页</button>";
		}
		if(checkpages <= {$matlist['pages']}){
			htmls = "<a href='?page="+checkpages+"'>";
			htmls += "<button type='button' class='layui-btn'>下一页</button>";
			htmls += "</a>";
		}else{
			htmls = "<button type='button' class='layui-btn layui-btn-disabled'>下一页</button>";
		}
		document.getElementById("prepage").innerHTML = html;
		document.getElementById("nextpage").innerHTML = htmls;
		var selectcate,selectmodid,mselectcate,mselectmodid;
			selectcate = xmSelect.render({
			el: '#cateid',
			style: {
					width: '150px',
				},
			data: 
			 	{$cate|raw}
			})
			selectmodid = xmSelect.render({
			el: '#modid',
			style: {
					width: '150px',
				},
			data: 
			 	{$model|raw}
			})
			mselectcate = xmSelect.render({
			el: '#mcateids',
			style: {
					width: '150px',
				},
			data: 
			 	{$cate|raw}
			})
			mselectmodid = xmSelect.render({
			el: '#mmodids',
			style: {
					width: '150px',
				},
			data: 
			 	{$model|raw}
			})
		function createall(){
			var aid = $("tbody input:checkbox");
			var ids = [];
			ids = allcheck(ids, aid,true);
			if (ids == "") {
				layer.msg('当前未选择任何信息!', {
					icon: 2,
					time: 2000
				});
			} else {
				ids = ids.substring(0, ids.length - 1);
				Data = {checkmat:1,checkmats: ids};
				layer.msg('确认生成选中文章?', {
					time: 3000, //5s后自动关闭
					shade: 0.3,
					btn: ['确定', '取消'],
					yes: function() {
						ajaxcrea(Data,"{:url('admin/Createdata/createmater')}");
					}
				});
			
			}
		}	
		function ajaxcrea(Data,url){
			$.ajax({
			    type: 'POST',
			    data: Data,
			    url: url,
			    dataType: "json",
			    beforeSend: function() {
			        index = layer.load();
			    },
			    success: function(data) {
			        if(data.code === 1){
			            layer.msg(data.msg, {time: 2000}, function() {
			                location.reload();
			            });
			        }else{
			            layer.msg(data.msg, {time: 2000});
			        }
			    },
			    complete: function() {
			        layer.close(index);
			    }
			});
		}	
		</script>
	</body>
</html>
